<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // function fn1(car){
        //     setTimeout(()=>{
        //         var bang="miku"
        //         console.log("我是异步任务1"+bang)
        //         car(bang);
        //     },2000)
        // }
        // function fn2(car){
        //     setTimeout(()=>{
        //         var bang="miku"
        //         console.log("我是异步任务2"+bang)
        //         car();
        //     },2000)
        // }
        // fn1(function(bang){fn2(function(bang){})})



        var fn1 = () => {
            return new Promise((resolve, reject) => {
                var bang = "miku"
                setTimeout(() => {
                    console.log(`我是异步任务1${bang}`)
                    resolve(bang);
                }, 2000)
            })
        }
        var fn2 = (bang) => {
            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    console.log(`我是异步任务2${bang}`)
                    resolve(bang);
                }, 2000)
            })
        }
        var fn3 = (bang) => {
            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    console.log(`我是异步任务3${bang}`)
                    console.log(`执行结束`)
                    resolve(bang);
                }, 2000)
            })
        }


        async function fun(){
            var bang=await fn1();
            bang=await fn2(bang);
            await fn3(bang);
        }
        fun();
    </script>
</body>

</html>